
# -*- coding: UTF-8 -*-
#xiaohei.python.seo.call.me:)
#win+python2.7.x
import urllib2
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
from bs4 import BeautifulSoup
def jd(url,code):
    page = urllib2.urlopen(url)
    html_doc = page.read()
    soup = BeautifulSoup(html_doc.decode('gb2312','ignore'))
    for i in soup.findAll('table'):
        tr = i.find_all('tr')
        for a in tr:
            tr = a.find_all('td')
            for b in tr:
                bb=b.text
                bc = bb.encode()
                if "公式为：净利润=利润总额-所得税费用" in bc:
                    abc= bc.replace(" ","")
                    outprint=code+">>>净利润:"+abc[0:6]
                    outprint=outprint.replace("公","")
                    print(outprint)
                if "公式为公司股票价格除以每股利润。该指标主要是衡量公司的价值，高市盈率一般是由高成长支撑着" in bc:
                    abcd= bc.replace(" ","")
                    outprint=">>>>>>>>>>>市盈率:"+abcd[0:6]
                    outprint=outprint.replace("公","")
                    print(outprint)

#jd("http://quote.eastmoney.com/sh603993.html")